#include<string.h>
#include<stdio.h>
#include<sys/socket.h>
#include<netinet/in.h>
		
#define	BUF_SIZE	1024

int main( int argc , char *argv[] )
{
	struct 	sockaddr_in host_address;
	int 	hst_addr_size = sizeof(host_address);
	char	dst[128];
	char 	buffer[BUF_SIZE];
	int 	sock;
	int 	port = 53;
	int 	length;
	int 	i;

	
	strncpy(dst,"140.114.78.142",strlen("140.114.78.142")-1);
	if ( argc == 3 ){
		for ( i = 0 ; i < 128 ; i++ ){
			dst[i] = 0;
		}
		strncpy(dst,argv[1],strlen(argv[1]));
		port = atoi(argv[2]);
	}
	printf("Send to %s port %d\n",dst,port);
	strncpy(buffer,"hacker",strlen("hacker"));

	sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	/*init the host_address the socket is beeing bound to*/
	memset((void*)&host_address, 0, sizeof(host_address));
	/*set address family*/
	host_address.sin_family		= PF_INET;
	/*accept any incoming messages:*/
	host_address.sin_addr.s_addr	= inet_addr(dst);
	/*the port the socket i to be bound to:*/
	host_address.sin_port		= htons(port);

	i = sendto( sock, buffer, strlen(buffer), 0, (struct sockaddr*)&host_address, hst_addr_size );
	printf("%d\n",i);
}
